package cn.powerone.scm.controller;

import java.util.List;

import cn.powerone.scm.domain.ScmSupplierQuotes;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.powerone.common.annotation.Log;
import cn.powerone.common.core.controller.BaseController;
import cn.powerone.common.core.domain.AjaxResult;
import cn.powerone.common.enums.BusinessType;
import cn.powerone.scm.domain.ScmEstimateQuotes;
import cn.powerone.scm.service.IScmEstimateQuotesService;
import cn.powerone.common.utils.poi.ExcelUtil;
import cn.powerone.common.core.page.TableDataInfo;

/**
 * 客户报价单Controller
 * 
 * @author PowerOne
 * @date 2025-07-02
 */
@RestController
@RequestMapping("/scm/scmEstimateQuotes")
public class ScmEstimateQuotesController extends BaseController
{
    @Autowired
    private IScmEstimateQuotesService scmEstimateQuotesService;

    /**
     * 查询客户报价单列表
     */
    @PreAuthorize("@ss.hasPermi('scm:scmEstimateQuotes:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScmEstimateQuotes scmEstimateQuotes)
    {
        startPage();
        List<ScmEstimateQuotes> list = scmEstimateQuotesService.selectScmEstimateQuotesList(scmEstimateQuotes);
        return getDataTable(list);
    }

    /**
     * 导出客户报价单列表
     */
    @PreAuthorize("@ss.hasPermi('scm:scmEstimateQuotes:export')")
    @Log(title = "客户报价单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScmEstimateQuotes scmEstimateQuotes)
    {
        List<ScmEstimateQuotes> list = scmEstimateQuotesService.selectScmEstimateQuotesList(scmEstimateQuotes);
        ExcelUtil<ScmEstimateQuotes> util = new ExcelUtil<ScmEstimateQuotes>(ScmEstimateQuotes.class);
        util.exportExcel(response, list, "客户报价单数据");
    }

    /**
     * 获取客户报价单详细信息
     */
    @PreAuthorize("@ss.hasPermi('scm:scmEstimateQuotes:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(scmEstimateQuotesService.selectScmEstimateQuotesById(id));
    }

    /**
     * 新增客户报价单
     */
    @PreAuthorize("@ss.hasPermi('scm:scmEstimateQuotes:add')")
    @Log(title = "客户报价单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScmEstimateQuotes scmEstimateQuotes)
    {
        return toAjax(scmEstimateQuotesService.insertScmEstimateQuotes(scmEstimateQuotes));
    }

    /**
     * 修改客户报价单
     */
    @PreAuthorize("@ss.hasPermi('scm:scmEstimateQuotes:edit')")
    @Log(title = "客户报价单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScmEstimateQuotes scmEstimateQuotes)
    {
        return toAjax(scmEstimateQuotesService.updateScmEstimateQuotes(scmEstimateQuotes));
    }

    /**
     * 删除客户报价单
     */
    @PreAuthorize("@ss.hasPermi('scm:scmEstimateQuotes:remove')")
    @Log(title = "客户报价单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scmEstimateQuotesService.deleteScmEstimateQuotesByIds(ids));
    }

    /**
     * Accept状态修改项目研讨价单
     */
    @PreAuthorize("@ss.hasPermi('scm:scmEstimateQuotes:update')")
    @PutMapping("/status/{ids}")
    public AjaxResult updateStatus(@PathVariable Long[] ids, @RequestBody ScmEstimateQuotes scmEstimateQuotes)
    {
        return toAjax(scmEstimateQuotesService.updateStatusScmSupplierQuotesByIds(ids, scmEstimateQuotes));
    }
}
